var Web3 = require('web3');

// var Accounts = require('web3-eth-accounts');
// var accounts = new Accounts('ws://localhost:8546');

var web3 = new Web3('ws://127.0.0.1:8545');

// let account = web3.eth.accounts.create();
// let account = web3.eth.accounts.create('2435@#@#@±±±±!!!!678543213456764321§34567543213456785432134567');
// let account = web3.eth.accounts.privateKeyToAccount("0x9a7e149b2277997673cb5f684c20f19ecac7370bf299b601e9446baa929135d4");

//////////////////////////////////////////////////////////////////
//签名
// let tx = {to:'0xb9ca164a1120426dadF5c92D3d4A097589379393', value:'1000000000', gas:2000000}
// web3.eth.accounts.signTransaction(tx, '0xd5b0e3bdc10d9196e214b6c7f5a938dc6172b864ba46096d17f5580869e13dd0').then(
//     function (data){console.info(data);});
//==>
// {
//     messageHash: '0x35ea244fc0f355501c91f4ecc1a2833875f44c4a4cee9ea205f76693bc4c5ab5',
//     v: '0x0a95',
//     r: '0xcbe0852e96cd0cc393c695fc30e61fad425bbce6f9ca06c9091eaafbb1f7fff9',
//     s: '0x5901ee8137046731c45222b835b7f3b2a19a284d6457b874e8fb2fbb4990bf11',
//     rawTransaction: '0xf86b808504a817c800831e848094b9ca164a1120426dadf5c92d3d4a097589379393843b9aca0080820a95a0cbe0852e96cd0cc393c695fc30e61fad425bbce6f9ca06c9091eaafbb1f7fff9a05901ee8137046731c45222b835b7f3b2a19a284d6457b874e8fb2fbb4990bf11',
//     transactionHash: '0xa91f04d41a6ba3417df40cf94eb018e830923f9c5673ab6ec1cf94734356bda2'
//   }

//
// web3.eth.accounts.sign('Some data', '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318');
//==>
// {
//     message: 'Some data',
//     messageHash: '0x1da44b586eb0729ff70a73c326926f6ed5a25f5b056e7f47fbc6e58d86871655',
//     v: '0x1c',
//     r: '0xb91467e570a6466aa9e9876cbcd013baba02900b8979d43fe208a4a4f339f5fd',
//     s: '0x6007e74cd82e037b800186422fc2da167c747ef045e5d18a5f5d4300f8e1a029',
//     signature: '0xb91467e570a6466aa9e9876cbcd013baba02900b8979d43fe208a4a4f339f5fd6007e74cd82e037b800186422fc2da167c747ef045e5d18a5f5d4300f8e1a0291c'
// }

//////////////////////////////////////////////////////////////////
//
// let addr = web3.eth.accounts.recoverTransaction('0xf86b808504a817c800831e848094b9ca164a1120426dadf5c92d3d4a097589379393843b9aca0080820a95a0cbe0852e96cd0cc393c695fc30e61fad425bbce6f9ca06c9091eaafbb1f7fff9a05901ee8137046731c45222b835b7f3b2a19a284d6457b874e8fb2fbb4990bf11');
// console.info(addr);


// let result = web3.eth.accounts.hashMessage("Hello World")
// console.info(result);


// web3.eth.accounts.recover(signatureObject);
// web3.eth.accounts.recover(message, signature [, preFixed]);
// web3.eth.accounts.recover(message, v, r, s [, preFixed]);

// let result = web3.eth.accounts.wallet;
let wallet = web3.eth.accounts.wallet.create(2, '54674321§3456764321§345674321§3453647544±±±§±±±!!!43534534534534');
// web3.eth.accounts.wallet.add("0x7468e9050a0a39620b3a8296ce7186d76d86fe9c5860c1544c42b0b77eb443b1");
// console.info(wallet);

let result = web3.eth.accounts.wallet.encrypt('test');
console.info(result);
